package com.project.service.employeeService.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.EmployeeBean;
import com.project.bean.ReviewBean;
import com.project.bean.ServeOrderBean;
import com.project.mapper.employeeMapper.IEmployeeMapper;
import com.project.service.employeeService.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    private IEmployeeMapper employeeMapper;

    @Override
    public void add(EmployeeBean employee) {
        employeeMapper.add(employee);
    }

    @Override
    public void del(int id) {
        employeeMapper.del(id);
    }

    @Override
    public void update(int id, String tel, String skill) {
        employeeMapper.update(id, tel, skill);
    }

    @Override
    public void updateState(int id, String work) {
        employeeMapper.updateState(id, work);
    }

    @Override
    public EmployeeBean findById(int id) {
        List<ServeOrderBean> list = employeeMapper.findByOrderId(id);
        EmployeeBean employee = employeeMapper.findById(id);
        employee.setServeOrderList(list);
        return employee;
    }

    @Override
    public List<EmployeeBean> findByState(int storeId) {
        return employeeMapper.findByState(1);
    }

    @Override
    public PageInfo<EmployeeBean> findBySkill(int pageNO, String skill,int storeId) {
        PageHelper.startPage(pageNO,PAGESIZE);
        return PageInfo.of(employeeMapper.findBySkill(skill,storeId));
    }

    @Override
    public PageInfo<EmployeeBean> findAll(int pageNO, int storeId) {
        PageHelper.startPage(pageNO,PAGESIZE);
        return PageInfo.of(employeeMapper.findAll(storeId));
    }

}
